package com.example.abc.jnidemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Arrays;

public class MainActivity extends AppCompatActivity {

    private TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv = ((TextView) findViewById(R.id.main_tv));
        tv.setText(getStringToC());
        Log.e("AAA-->", "onCreate: " + getIntToC(1,2));
        int [] array = new int[] {2, 5, 6, 3, 7};
        Log.e("AAA-->", "onCreate: " + getArrayLength(array));
        sort(array);
        Log.e("AAA-->", "onCreate: " + Arrays.toString(array));
        getArray(array);
        Log.e("AAA-->", "onCreate: " + Arrays.toString(array));
    }

    static {
        System.loadLibrary("my_lib");
    }
    public native String getStringToC();

    public native int getIntToC(int a, int b);

    public native int[] sort(int[] array);

    public native int getArrayLength(int[] array);

    public native void getArray(int[] array);

    public native void fromCToast();

    public void showToast(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    public void click(View view) {
        fromCToast();
    }
}
